gtk/*: Use g_list_free_full() convenience function
authorJavier Jardón <jjardon@gnome.org>
Mon, 2 Jan 2012 03:20:59 +0000 (04:20 +0100)
committerJavier Jardón <jjardon@gnome.org>
Thu, 5 Jan 2012 03:22:43 +0000 (04:22 +0100)
21 files changed:
gtk/gtkdnd.c
gtk/gtkfilechooserdefault.c
gtk/gtkicontheme.c
gtk/gtkiconview.c
gtk/gtklabel.c
gtk/gtkpapersize.c
gtk/gtkprintunixdialog.c
gtk/gtkquery.c
gtk/gtkrecentchooser.c
gtk/gtkrecentchooserdefault.c
gtk/gtkrecentchoosermenu.c
gtk/gtkrecentchooserutils.c
gtk/gtksearchenginesimple.c
gtk/gtkstylecontext.c
gtk/gtktextbufferrichtext.c
gtk/gtktextbufferserialize.c
gtk/gtktreeview.c
gtk/gtkuimanager.c
gtk/gtkwidget.c
gtk/gtkwindow.c
gtk/updateiconcache.c

index ac33fd8a621e98353d094231fdff66936fff90b2..38911799357de2f56ea5b4237a152c81ce29143c 100644 (file)
@@ -2003,8 +2003,7 @@ gtk_drag_find_widget (GtkWidget           *widget,
             g_object_add_weak_pointer (G_OBJECT (parent), (gpointer *) &parent);
         }
 
-      g_list_foreach (hierarchy, (GFunc) g_object_unref, NULL);
-      g_list_free (hierarchy);
+      g_list_free_full (hierarchy, g_object_unref);
 
       if (found)
         return TRUE;
index 280e49102cd44b690d9a0e2f761023ad5c7df3a7..f08d36bed0603b6610983059903685f1a93aed97 100644 (file)
@@ -820,8 +820,7 @@ shortcuts_free (GtkFileChooserDefault *impl)
 static void
 pending_select_files_free (GtkFileChooserDefault *impl)
 {
-  g_slist_foreach (impl->pending_select_files, (GFunc) g_object_unref, NULL);
-  g_slist_free (impl->pending_select_files);
+  g_slist_free_full (impl->pending_select_files, g_object_unref);
   impl->pending_select_files = NULL;
 }
 
index 66e03adddd478a061beb2023d3d9030c5003d790..4f86cc753bcd4fe6cb5ee7e6c1471383262d0eaf 100644 (file)
@@ -734,10 +734,8 @@ blow_themes (GtkIconTheme *icon_theme)
   if (priv->themes_valid)
     {
       g_hash_table_destroy (priv->all_icons);
-      g_list_foreach (priv->themes, (GFunc)theme_destroy, NULL);
-      g_list_free (priv->themes);
-      g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL);
-      g_list_free (priv->dir_mtimes);
+      g_list_free_full (priv->themes, (GDestroyNotify) theme_destroy);
+      g_list_free_full (priv->dir_mtimes, (GDestroyNotify) free_dir_mtime);
       g_hash_table_destroy (priv->unthemed_icons);
     }
   priv->themes = NULL;
@@ -2021,8 +2019,7 @@ theme_destroy (IconTheme *theme)
   g_free (theme->name);
   g_free (theme->example);
 
-  g_list_foreach (theme->dirs, (GFunc)theme_dir_destroy, NULL);
-  g_list_free (theme->dirs);
+  g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
   
   g_free (theme);
 }
@@ -2721,8 +2718,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
   g_free (icon_info->filename);
   if (icon_info->loadable)
     g_object_unref (icon_info->loadable);
-  g_slist_foreach (icon_info->emblem_infos, (GFunc)gtk_icon_info_free, NULL);
-  g_slist_free (icon_info->emblem_infos);
+  g_slist_free_full (icon_info->emblem_infos, (GDestroyNotify) gtk_icon_info_free);
   if (icon_info->pixbuf)
     g_object_unref (icon_info->pixbuf);
   if (icon_info->cache_pixbuf)
index 79f94db49478ac16c2a905ac9078b64362dcfa8b..90069fc69f674ebc26b143a7c4bb40a2aac28cb7 100644 (file)
@@ -4768,8 +4768,7 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
 
       g_object_unref (icon_view->priv->model);
       
-      g_list_foreach (icon_view->priv->items, (GFunc)gtk_icon_view_item_free, NULL);
-      g_list_free (icon_view->priv->items);
+      g_list_free_full (icon_view->priv->items, (GDestroyNotify) gtk_icon_view_item_free);
       icon_view->priv->items = NULL;
       icon_view->priv->anchor_item = NULL;
       icon_view->priv->cursor_item = NULL;
@@ -5180,8 +5179,7 @@ gtk_icon_view_unselect_path (GtkIconView *icon_view,
  *
  * To free the return value, use:
  * |[
- * g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- * g_list_free (list);
+ * g_list_free_full (list, (GDestroyNotify) gtk_tree_patch_free);
  * ]|
  *
  * Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row.
index 589f20a9e61343bc3569e29a2aac8a63bc79b98c..5ca9b1dc5fac192a14b0576f1682ecde625386e6 100644 (file)
@@ -2509,8 +2509,7 @@ parse_uri_markup (GtkLabel     *label,
 failed:
   g_markup_parse_context_free (context);
   g_string_free (pdata.new_str, TRUE);
-  g_list_foreach (pdata.links, (GFunc)link_free, NULL);
-  g_list_free (pdata.links);
+  g_list_free_full (pdata.links, (GDestroyNotify) link_free);
   gdk_color_free (pdata.link_color);
   gdk_color_free (pdata.visited_link_color);
 
@@ -6267,8 +6266,7 @@ gtk_label_clear_links (GtkLabel *label)
   if (!priv->select_info)
     return;
 
-  g_list_foreach (priv->select_info->links, (GFunc)link_free, NULL);
-  g_list_free (priv->select_info->links);
+  g_list_free_full (priv->select_info->links, (GDestroyNotify) link_free);
   priv->select_info->links = NULL;
   priv->select_info->active_link = NULL;
 }
index 06852c0a05a8076425b0447e9571811bb2bc94df..7ed892b3a4064ee7ff6e7d54e8ffa8c0af923b10 100644 (file)
@@ -490,8 +490,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
           list = g_list_prepend (list, gtk_paper_size_copy (size));
         }
 
-      g_list_foreach (page_setups, (GFunc) g_object_unref, NULL);
-      g_list_free (page_setups);
+      g_list_free_full (page_setups, g_object_unref);
     }
 #endif
   for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)
index 091109e441f9a47373e031441e7b639628ddc677..15fdaafc2af033897845ea884e9e5cf0e6362e70 100644 (file)
@@ -1540,8 +1540,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
   else
     gtk_widget_hide (priv->advanced_page);
 
-  g_list_foreach (groups, (GFunc) g_free, NULL);
-  g_list_free (groups);
+  g_list_free_full (groups, g_free);
 }
 
 static void
index 6b17c74aee125b6f470177201884efc2c2d2f821..74879e0e91e850e427c3f01ef26064c27a9eaabd 100644 (file)
@@ -121,8 +121,7 @@ _gtk_query_set_mime_types (GtkQuery *query,
   GList *l;
   gchar *mime_type;
 
-  g_list_foreach (query->priv->mime_types, (GFunc)g_free, NULL);
-  g_list_free (query->priv->mime_types);
+  g_list_free_full (query->priv->mime_types, g_free);
   query->priv->mime_types = NULL;
 
   for (l = mime_types; l; l = l->next)
index b6873ec5d4afa72fc75664d9b2e922ee7d141636..81203e2fe9f455d2418b85d7a255e4d45ecf946a 100644 (file)
@@ -895,10 +895,7 @@ gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
   if (length)
     *length = i;
   
-  g_list_foreach (items,
-                 (GFunc) gtk_recent_info_unref,
-                 NULL);
-  g_list_free (items);
+  g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
   
   return retval;
 }
index b524a906a112e1618f50285de9fe3a3627dd70e2..88b3169ac9577e76b6629784d4a3961c07d3d72f 100644 (file)
@@ -629,12 +629,8 @@ gtk_recent_chooser_default_dispose (GObject *object)
       impl->load_id = 0;
     }
 
-  if (impl->recent_items)
-    {
-      g_list_foreach (impl->recent_items, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (impl->recent_items);
-      impl->recent_items = NULL;
-    }
+  g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
+  impl->recent_items = NULL;
 
   if (impl->manager && impl->manager_changed_id)
     {
@@ -839,10 +835,7 @@ load_recent_items (gpointer user_data)
       /* we have finished loading, so we remove the items cache */
       impl->load_state = LOAD_LOADING;
       
-      g_list_foreach (impl->recent_items,
-                     (GFunc) gtk_recent_info_unref,
-                     NULL);
-      g_list_free (impl->recent_items);
+      g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
       
       impl->recent_items = NULL;
       impl->n_recent_items = 0;
index 4e8856191e579111527d533b4336cd58cd43937f..10eee3f331667c29fcdf46b4e4f97d86884e4711 100644 (file)
@@ -1055,8 +1055,7 @@ check_and_return:
 
   if (pdata->loaded_items == pdata->n_items)
     {
-      g_list_foreach (pdata->items, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (pdata->items);
+      g_list_free_full (pdata->items, (GDestroyNotify) gtk_recent_info_unref);
 
       priv->populate_id = 0;
 
index 54f0ff5ce5e3889b101acacfec22f02d2ee7403a..6425a0f20228b59aa601c400f676def6948d0f3c 100644 (file)
@@ -525,8 +525,7 @@ _gtk_recent_chooser_get_items (GtkRecentChooser  *chooser,
       l = clamp->next;
       clamp->next = NULL;
     
-      g_list_foreach (l, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (l);
+      g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
     }
 
   return items;
index 515dd687cfe68efb53a4fa0b3b04693bab409118..55e8f7b9e1f66775aa34c0ea7e238850375a6923 100644 (file)
@@ -168,8 +168,7 @@ search_thread_add_hits_idle (gpointer user_data)
                                    hits->uris);
     }
 
-  g_list_foreach (hits->uris, (GFunc)g_free, NULL);
-  g_list_free (hits->uris);
+  g_list_free_full (hits->uris, g_free);
   g_free (hits);
        
   return FALSE;
index 0a6b43ce7ce347c01885015f1824bb07d52b7661..ac48bc65c41d2823dd34681473419322ab20488e 100644 (file)
@@ -584,8 +584,7 @@ style_data_free (StyleData *data)
   g_object_unref (data->store);
   clear_property_cache (data);
 
-  g_slist_foreach (data->icon_factories, (GFunc) g_object_unref, NULL);
-  g_slist_free (data->icon_factories);
+  g_slist_free_full (data->icon_factories, g_object_unref);
 
   g_slice_free (StyleData, data);
 }
@@ -806,11 +805,9 @@ gtk_style_context_finalize (GObject *object)
 
   g_hash_table_destroy (priv->style_data);
 
-  g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL);
-  g_list_free (priv->providers);
+  g_list_free_full (priv->providers, (GDestroyNotify) style_provider_data_free);
 
-  g_slist_foreach (priv->info_stack, (GFunc) style_info_free, NULL);
-  g_slist_free (priv->info_stack);
+  g_slist_free_full (priv->info_stack, (GDestroyNotify) style_info_free);
 
   g_slist_free (priv->animation_regions);
 
index e4e6836afcf6f29e5768cdb4ac49706d32547905..071f5e1c6c306d572b35a30790e596f4858bbb7b 100644 (file)
@@ -797,8 +797,7 @@ free_format (GtkRichTextFormat *format)
 static void
 free_format_list (GList *formats)
 {
-  g_list_foreach (formats, (GFunc) free_format, NULL);
-  g_list_free (formats);
+  g_list_free_full (formats, (GDestroyNotify) free_format);
 }
 
 static GQuark
index c750a80f0a2568db665d59aedd78ee4145873745..98ef116f37b8d21562ca6cdde2a67a534e9dafd1 100644 (file)
@@ -1784,8 +1784,7 @@ read_headers (const gchar *start,
   return g_list_reverse (headers);
 
  error:
-  g_list_foreach (headers, (GFunc) g_free, NULL);
-  g_list_free (headers);
+  g_list_free_full (headers, g_free);
 
   g_set_error_literal (error,
                        G_MARKUP_ERROR,
@@ -1879,8 +1878,7 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
                             create_tags, error, headers->next);
 
  out:
-  g_list_foreach (headers, (GFunc)g_free, NULL);
-  g_list_free (headers);
+  g_list_free_full (headers, g_free);
 
   return retval;
 }
index b01273a71b0329bc74370f2871924b637ec66e4c..394f0c6911d5c4b69eae59ef061844841d6868d3 100644 (file)
@@ -10148,8 +10148,7 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
       if (selected_rows)
        {
           cursor_path = gtk_tree_path_copy((const GtkTreePath *)(selected_rows->data));
-         g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
-         g_list_free (selected_rows);
+         g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
         }
       else
        {
index b4268654327314a49247646296b19ca9a2728d81..82c638c4e2bbbd36d7809e017af08c5f269b333a 100644 (file)
@@ -680,9 +680,7 @@ gtk_ui_manager_finalize (GObject *object)
   g_node_destroy (manager->private_data->root_node);
   manager->private_data->root_node = NULL;
   
-  g_list_foreach (manager->private_data->action_groups,
-                  (GFunc) g_object_unref, NULL);
-  g_list_free (manager->private_data->action_groups);
+  g_list_free_full (manager->private_data->action_groups, g_object_unref);
   manager->private_data->action_groups = NULL;
 
   g_object_unref (manager->private_data->accel_group);
@@ -1392,8 +1390,7 @@ free_node (GNode *node)
 {
   Node *info = NODE_INFO (node);
   
-  g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL);
-  g_list_free (info->uifiles);
+  g_list_free_full (info->uifiles, node_ui_reference_free);
 
   if (info->action)
     g_object_unref (info->action);
index fe790f9958e78450ef31e35dc5bd5d079c931804..a830741129ae674ffed5ba89f18fb17b099ca38f 100644 (file)
@@ -12030,8 +12030,7 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
        }
       g_object_unref (relation_set);
 
-      g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
-      g_slist_free (atk_relations);
+      g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
       g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
                          NULL);
     }
@@ -12438,8 +12437,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
           else
             g_warning ("accessibility action on a widget that does not implement AtkAction");
 
-         g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
-         g_slist_free (a11y_data->actions);
+         g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
        }
 
       if (a11y_data->relations)
index f61e4a2ea12e1304b5ada9e006cdfff4fc8bea47..62e75ee45a3a1867d3bdbe38abd2abe1a9077839 100644 (file)
@@ -3482,8 +3482,7 @@ gtk_window_realize_icon (GtkWindow *window)
     {
       GtkIconTheme *icon_theme;
 
-      g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
-      g_list_free (icon_list);
+      g_list_free_full (icon_list, g_object_unref);
  
       icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
       g_signal_connect (icon_theme, "changed",
@@ -3564,10 +3563,7 @@ gtk_window_set_icon_list (GtkWindow  *window,
   g_list_foreach (list,
                   (GFunc) g_object_ref, NULL);
 
-  g_list_foreach (info->icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (info->icon_list);
+  g_list_free_full (info->icon_list, g_object_unref);
 
   info->icon_list = g_list_copy (list);
 
@@ -3695,8 +3691,7 @@ gtk_window_set_icon_name (GtkWindow   *window,
   info->icon_name = g_strdup (name);
   g_free (tmp);
 
-  g_list_foreach (info->icon_list, (GFunc) g_object_unref, NULL);
-  g_list_free (info->icon_list);
+  g_list_free_full (info->icon_list, g_object_unref);
   info->icon_list = NULL;
   
   update_themed_icon (NULL, window);
@@ -3839,10 +3834,7 @@ gtk_window_set_default_icon_list (GList *list)
   g_list_foreach (list,
                   (GFunc) g_object_ref, NULL);
 
-  g_list_foreach (default_icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (default_icon_list);
+  g_list_free_full (default_icon_list, g_object_unref);
 
   default_icon_list = g_list_copy (list);
   
@@ -3911,10 +3903,7 @@ gtk_window_set_default_icon_name (const gchar *name)
   g_free (default_icon_name);
   default_icon_name = g_strdup (name);
 
-  g_list_foreach (default_icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (default_icon_list);
+  g_list_free_full (default_icon_list, g_object_unref);
   default_icon_list = NULL;
   
   /* Update all toplevels */
index 6988215714e4fe0aa47ecd561dcc324128e2936f..95db497f38dfa592410d34ba6aac34dd79e1d239 100644 (file)
@@ -1525,8 +1525,7 @@ opentmp:
     }
   cache = NULL;
 
-  g_list_foreach (directories, (GFunc)g_free, NULL);
-  g_list_free (directories);
+  g_list_free_full (directories, g_free);
 
   if (!validate_file (tmp_cache_path))
     {